<!--# layout("/common/mallout.html"){ -->

<link rel="stylesheet" href="http://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop/mall/style/product.css">
<!--<link rel="stylesheet" href="https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop%2Fmall%2Fimage%2Fbase.css">-->
<!--<link rel="stylesheet" href="https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop%2Fmall%2Fimage%2Fproduct.css">-->

<style>
    .the_custom_ipt{
        width: 68px;
        height: 30px;
        border: 1px solid #cccccc;
        font-weight: 200;
    }
</style>

<div id="hiddenParam">
    <input type="hidden" id="hiddenGoodsId" value="${goodsId}">
    <input type="hidden" id="hiddenGoodsType" value="${goodsType}">
    <input type="hidden" id="fileNum" value="">
    <input type="hidden" id="append" value="">
</div>
<div id="detail"></div>

<div class="breadcrumb">
    <div class="bread-crumbs">
        <div class="bread_left">
            <div class="bread-crumbs">
				<a href="/index.do">首页</a>
        	<span id="indexHtml">
			</span>
                <script type="text/html" id="category">
                    {{ each categoryMap category key}}
                    <span class="arrows">»</span>
                    <span class="now"><a href="/mall/category.do?categoryId={{key}}&goodsType={{goodsType}}">{{category}}</a>
                                </span>
                    {{ /each }}
                    <input type="hidden" class="parameter" id="shopId" value="{{sellerDetail['merchantId']}}">
                    <input type="hidden" class="parameter" id="goodsType" value="{{goodsType}}">
                    <input type="hidden" class="parameter" id="store" value="{{store}}">
                    <input type="hidden" class="parameter" id="spuId" value="{{spu}}">
                    <input type="hidden" class="parameter" id="isNoStoreSell" value="{{isNoStoreSell}}">
                    <input type="hidden" class="parameter" id="quoteCategoryType" value="{{quoteCategoryType}}">
                </script>
            </div>
        </div>
    </div>
</div>


<!--保存自定义html-->

<div id="defindHtml" style="display:none;">


</div>

<script type="text/html" id="defind">
<ul class="def1">
    {{each partAttrOptionList as part }}
    <li clsid="{{part['partId']}}" status="{{part['partMustChoose'] == false ? 'hide' : 'show'}}">
        <ul class="def2"  >
            {{each part['attrOptionListsInfoList'] attr }}
                {{if attr['attrSquare']['customMade'] == true }}
                <div class="defindDiv" id="div_{{attr['attrSquare']['id']}}_{{part['partId']}}"></div>
                {{/if}}
                {{if attr['attrSquare']['attributeType'] == 'material' }}
                <div class="paperDiv" id="div_{{attr['attrSquare']['id']}}_{{part['partId']}}"></div>
                {{/if}}
            {{/each}}
        </ul>
    </li>
    {{/each}}
</ul>
</script>

<script type="text/html" id="left">

    <!----------左侧----------->

    <div class="product-album-preview">
        {{if goodsInfoDetail['defaultImage'] !=null }}
        <img src="${imagepath}/{{goodsInfoDetail['defaultImage']}}">
        {{else}}
        <img src="https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop/mall/image/pic_pop_02.png">
        {{/if}}
    </div>
    <div class="product-album-thumb">
        <span class="flip_prev flip"></span>
        <div class="thumbnail-list">
            <ul>
                {{each goodsInfoDetail['imageUrls'] url}}
                <li>
                    <a href="javascript:">
                        <img src="${imagepath}/{{url}}">
                    </a>
                </li>

                {{/each}}
            </ul>
        </div>
        <span class="flip_next flip"></span>
    </div>
    <!-- 分享推荐收藏 -->
</script>


<!-------------------------------------->
<div class="center">
    <div class="section">
        <!-- 商品详情 -->
        <div class="page-maincontent">

            <!--左侧-->
            <div class="product-side product-img" id="leftHtml">
                <!--默认适配地图-->
                <div class="product-album-preview">
                    <img src="https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop/mall/image/pic_pop_04.png">
                </div>
            </div>

            <!----------右侧---------->
            <div class="product-titles titles">
                <h2 id="spuName"></h2>
                <p id="brief"></p>
            </div>

            <div id="rightHtml">
                <!--默认适配地图-->
                <div class="product-titles titles">
                    <h2>报价商品</h2>
                </div>
                <div class="product-spec-box" id="rightHtml">

                    <!--------------工艺参数-------------------------->
                    <div class="product-spec-price-shipping product-buy">
                            <span partid="13814" class="partParam">
                            <div class="product-spec-price-box AttributeOptionDto">
                               <span class="item-label" optionid="13" attributetype="normal" attributekey="" influencecraftpricetype="">产品尺寸:</span>
                                <div class="item-content">
                                    <span class="spec-attr atver  normal  " specvalueid="85">90x54mm(常规尺寸)<em></em></span>
                                </div>
                            </div>
                            </span>
                    </div>
                </div>
            </div>

                <div class="product-spec-price-box" style="float: right;margin-top: 10px;">
                    <span class="item-label" style="padding-right: 6px;">区域选择:</span>
                    <div class="item-content">
                             <span class="spec-attr address_text">
                            	<a href="javascript:void(0)">湖北 武汉市 江汉区</a><s></s>
                                <div class="address_select">
                                    <div class="address_tab">
                                        <span class="atver"><i>湖北</i></span>
                                        <span><i>武汉</i></span>
                                        <span><i>江汉区</i></span>
                                    </div>
                                    <div style="display:none;">
                                        <select class="address_op"></select>
                                        <select class="address_op"></select>
                                        <select class="address_op"></select>
                                    </div>
                                    <div class="address_con">

                                    </div>
                                    <div class="address_con">

                                    </div>
                                    <div class="address_con">

                                    </div>
                                </div>
                             </span>
                    </div>
                </div>
                <div class="product-spec-price-box" style="float: right;margin-top: 10px;margin-bottom: -5px;">
                    <span class="item-label"></span>
                    <div class="item-content" style="margin-top: 5px;">
                        <span style="height: 30px;padding-left: 14px;box-sizing: border-box;display: inline-block;width: 450px;background:#f1eefa;line-height: 30px;color: #333;margin-left: 10px;">此商品由 <a href=" javascript:void(0) " class="red_price merchantName"></a> 发货, 并提供售后服务.</span><br>
                        <span style="height: 30px;padding-left: 14px;box-sizing: border-box;display: inline-block;width: 450px;background:#f1eefa;line-height: 30px;color: #333;margin-left: 10px;">此门店电话为：<a class="red_price mobile"></a></span>
                    </div>
                </div>
                <!----------参数分类  模块end----------------->
                <div class="product-spec-price-box" >
                    <span class="item-label"></span>
                    <div class="item-content" style="float: right;">
                        <button type="submit" class="action-addtocart" id="buynow">立即购买</button>
                        <button type="submit" class="action-addtocart" id="addcart">加入购物车</button>
                    </div>
                <div class="product-spec-price-box" style="float: right" id="canUploadFile">
                    <span class="item-label">附件:</span>
                    <div class="item-content" style="vertical-align:inherit">
                        <div class="action-uploadFile" id="uploadFile">上传附件</div>
                        <span style="position: relative;margin-left: 15px;top: 35px">
                            <span class="file_info_list picture" style="position: absolute;left: 0px;right: 0px ;height: 30px; width: 185px; display: inline-block; vertical-align: middle;padding: 2px;overflow: hidden">
                            </span>
                        </span>
                        <span style="margin-left: 180px;cursor: pointer;display: none" class="moreFile">更多</span>
                    </div>
                </div>

<script type="text/html" id="right">

            <div class="product-spec-box" id="rightHtml">
                <div class="product-titles">
                    <!--------------页面影藏参数-------------------------->
                    <input type="hidden" class="parameter" id="templetId" value="{{freightTemplateId}}">
                </div>

                <div class="product-spec-price-shipping product-buy">
                    <ul class="level1">
                        {{ each partAttrOptionList as part}}
                            <input type="hidden" {{craftNum = 0}} >
                        <input type="hidden" {{openCraftNum = 0}} >
                        <li class="product" clsid="{{part['partId']}}">
                            {{ if part['partMustChoose'] == true }}
                                <ul class="product-buy-ul level2" noneId="{{part['partId']}}">
                            {{else}}
                                <ul class="product-buy-ul level2" noneId="{{part['partId']}}" style="display: none">
                             {{/if}}

                                    <li>
                                        <div class="partTitle"><label class="label">{{ partAttrOptionList.length == 1 ? '': part['partName']}}</label>
                                            {{each part['attrOptionListsInfoList'] as attr}}
                                            {{if attr['attrSquare']['attributeType'] == 'craft' && attr['attrSquare']['mustSquares'] !=true }}
                                            <input type="hidden" {{craftNum++}}>
                                            {{each attr['optionDTO'] as opt }}
                                            {{if opt['defaultOption'] == true}} <input type="hidden" {{openCraftNum++}} >{{/if}}
                                            {{/each}}
                                            {{/if}}
                                            {{/each}}
                                            {{ if craftNum > 0}}
                                            <p class="item-con-01" gongyiId="{{part['partId']}}" >
                                                <em class="tianjia  {{openCraftNum>0? 'atv':''}}"><em></em><strong>添加工艺</strong></em>
                                            </p>
                                            {{/if}}
                                        </div>

                                        <div class="mainBody">
                                        <div class="product-list-can">
                                            {{ each part['attrOptionListsInfoList'] as attr }}

                                            <!--隐藏的必选属性-->
                                                    {{if attr['attrSquare']['display'] == false && attr['attrSquare']['mustSquares'] == true }}
                                                    <p class="item-con-01 attr_hide" optionid="{{attr['attrSquare']['id']}}" style="display:none;" attributeValueType="{{attr['attrSquare']['attributeValueType']}}">
                                                        <i>{{attr['attrSquare']['squareName']}}</i>

                                                        {{each attr['optionDTO'] as option}}
                                                        <span class="item-con-01-span {{option['defaultOption']== true? 'atv':''}} {{option['optionCanChoose']== true ? '':'mutual'}} " specvalueid="{{option['id']}}" attributevaluetype="{{attr['attrSquare']['attributeValueType']}}">{{option['squareName']}}<em></em></span>
                                                        {{/each}}
                                                    </p>
                                                    {{/if}}

                                            {{ if attr['attrSquare']['attributeType'] == 'normal' || (attr['attrSquare']['attributeType'] == 'craft' && attr['attrSquare']['mustSquares'] == true && attr['attrSquare']['display'] == true) }}
                                                <input type="hidden" {{d=0}} {{x=0}} {{canDef=0}} {{nl = 0}}>
                                                {{each attr['optionDTO'] option }}
                                                {{if option['customMade'] == true}}
                                                <input type="hidden" {{d=1}}  {{canDef = 1}}>
                                                {{/if}}
                                                {{/each}}
                                                {{if attr['attrSquare']['customMade'] == true && d != 1}}
                                                <input type="hidden" {{x=1}} >
                                                {{/if}}

                                            {{if attr['optionDTO'].length <= 3}}
                                            <input type="hidden"   {{nl= attr['optionDTO'][0]['squareName'].length>10? 1:0}}>
                                            {{/if}}

                                            <p class="item-con-01" {{nl==1? 'style=position:relative;padding-left:85px;box-sizing:border-box;' : ''}} attributeValueType="{{attr['attrSquare']['attributeValueType']}}" optionid="{{attr['attrSquare']['id']}}" attributetype="{{attr['attrSquare']['attributeType']}}" attributekey="{{attr['attrSquare']['attributeKey']}}" influencexraftpricetype="{{attr['attrSquare']['influenceCraftPriceType']}}" joinbuildsku="{{attr['attrSquare']['joinBuildSku']}}">


                                                <i  {{nl==1? 'style=position:absolute;left:5px;' : ''}}> {{attr['attrSquare']['squareName']}}</i>

                                                {{if attr['optionDTO'].length <= 3}}
                                                {{each attr['optionDTO'] option}}
                                                <span  {{nl==1? 'style=width:245px;margin-bottom:5px' : ''}} class="item-con-01-span {{option['defaultOption']== true? 'atv':''}}  {{option['optionCanChoose']== true ? '':'mutual'}}" defId="{{attr['attrSquare']['id']}}" parentId="{{part['partId']}}"  specvalueid="{{option['id']}}"  definitionlength="{{option['customLimitValue']}}">{{option['squareName']}}<em></em></span>
                                                {{/each}}

                                                {{else}}
                                                <span class="item-con-01-span" >
                                                <select class="ziding_dow">
                                                    {{each attr['optionDTO'] as option}}
                                                    <option value="{{option['id']}}" style="display: {{option['optionCanChoose'] == true? 'block':'none'}}" {{option['defaultOption'] == true ? 'selected':''}} >{{option['squareName']}}</option>
                                                    {{/each}}
                                                </select>
                                                </span>
                                                {{/if}}
                                            </p>


                                            <p class="item-con defindArea" optionid="{{attr['attrSquare']['id']}}" parentId="{{part['partId']}}" attrcandef="{{canDef == 1?'1':0}}">
                                            <span class="the_custom {{ x==1 ? '':'noClick'}}" style="display:{{x==1 ? '':'none'}};" defId="{{attr['attrSquare']['id']}}" id="son_{{attr['attrSquare']['id']}}_{{part['partId']}}" parentId="{{part['partId']}}" val="{{attr['attrSquare']['customLimitValue']}}" attributeValueType="{{attr['attrSquare']['attributeValueType']}}"><em></em>自定义</span>
                                                <span class="defInput"  id="span_{{attr['attrSquare']['id']}}_{{part['partId']}}"  parentId="{{part['partId']}}" defId="{{attr['attrSquare']['id']}}" attributeValueType="{{attr['attrSquare']['attributeValueType']}}"></span>
                                            </p>

                                            {{/if}}


                                            {{if attr['attrSquare']['attributeType'] == 'material' }}
                                            <input type="hidden" {{optionKey = "" }} >

                                                <p class="item-con-01" attributeValueType="{{attr['attrSquare']['attributeValueType']}}" optionid="{{attr['attrSquare']['id']}}" attributetype="{{attr['attrSquare']['attributeType']}}" attributekey="{{attr['attrSquare']['attributeKey']}}" influenceCraftPriceType="{{attr['attrSquare']['influenceCraftPriceType']}}" joinBuildSku="{{attr['attrSquare']['joinBuildSku']}}" >
                                                    <i>{{attr['attrSquare']['squareName']}}</i>
                                                    <span class="item-con-01-span">
                                                         {{ each attr['optionDTO'] option}}
                                                         {{if option['defaultOption'] == true }}
                                                           <input type="hidden" {{optionKey = option['attributeKey'] }} >
                                                           {{/if}}
                                                         {{/each}}
                                                   <select class="materialKey">
                                                       {{ each attr['optionDTO'] option}}
                                                       <option value="{{option['attributeKey']}}" {{option['defaultOption'] == true ? 'selected' : '' }} >{{option['squareName']}}</option>
                                                       {{/each}}
                                                   </select>
                                               </span>

                                                <span class="item-con-01-span">
                                                   <select class="optionKey">
                                                        {{ each attr['optionDTO'] option}}
                                                            {{each option['sonOptionList'] son}}
                                                            {{if son['attributeKey'] == optionKey}}
                                                                <option style="display: {{son['optionCanChoose'] == true ? 'block':'none'}}" value="{{son.id}}" optionKey="{{son['attributeKey']}}" {{son['defaultOption'] == true? 'selected' : ''}}>{{son['squareName']}}</option>
                                                       {{else}}
                                                                <option style="display: none" value="{{son.id}}" optionKey="{{son['attributeKey']}}" >{{son['squareName']}}</option>
                                                       {{/if}}
                                                            {{/each}}
                                                        {{/each}}
                                                   </select>
                                               </span>
                                                </p>

                                                {{ if part['selfPaper'] == true}}
                                            <p class="item-con">
                                                <span class="the_custom the_selfPaper " id="self_{{attr['attrSquare']['id']}}_{{part['partId']}}"><em></em>自来纸</span>
                                            </p>
                                                {{/if}}
                                            {{/if}}

                                            <!--{{if attr['attrSquare']['attributeType'] == 'craft' && attr['attrSquare']['mustSquares'] !=true }}-->
                                            <!--<input type="hidden" {{craftNum++}}>-->

                                            <!--{{each attr['optionDTO'] as opt }}-->
                                            <!--{{if opt['defaultOption'] == true}} <input type="hidden" {{openCraftNum++}} >{{/if}}-->
                                            <!--{{/each}}-->

                                            <!--{{/if}}-->

                                            <!--{{/each}}-->
                                        </div>

                                        </div>
                                                <!--{{ if craftNum > 0}}-->
                                                <!--<p class="item-con-01" gongyiId="{{part['partId']}}" >-->
                                                    <!--<em class="tianjia  {{openCraftNum>0? 'atv':''}}"><em></em><strong>添加工艺</strong></em>-->
                                                <!--</p>-->
                                                <!--{{/if}}-->
                                                <li class="gongyi" gongyiId="{{part['partId']}}" style="display: {{openCraftNum>0? 'block':'none'}}">
                                                    <label class="label">{{part['partName']}}：</label>
                                                    <div class="product-list-can">
                                                        {{ each part['attrOptionListsInfoList'] as attr }}
                                                        {{if attr['attrSquare']['attributeType'] == 'craft' && attr['attrSquare']['mustSquares']!=true }}
                                                        <p class="item-con-02" attributeValueType="{{attr['attrSquare']['attributeValueType']}}" optionid="{{attr['attrSquare']['id']}}" attributetype="{{attr['attrSquare']['attributeType']}}" attributekey="{{attr['attrSquare']['attributeKey']}}" influenceCraftPriceType="{{attr['attrSquare']['influenceCraftPriceType']}}" joinBuildSku="{{attr['attrSquare']['joinBuildSku']}}">
                                                            <input type="hidden" {{canOpen = 0}} >

                                                            {{each attr['optionDTO'] as opt }}

                                                            {{if opt['defaultOption'] == true}} <input type="hidden" {{canOpen++}} >{{/if}}
                                                            {{/each}}

                                                            <i class="atv_show {{canOpen>0? 'atv':''}} "  customLimitValue="{{attr['attrSquare']['customLimitValue']}}" defId="{{attr['attrSquare']['id']}}" parentId="{{part['partId']}}" attributeValueType="{{attr['attrSquare']['attributeValueType']}}" ><em></em>{{attr['attrSquare']['squareName']}}</i>
                                                            {{each attr['optionDTO'] as opt }}
                                                            {{if canOpen>0 }}
                                                                <span class="item-con-02-span  {{opt['defaultOption'] == true ? 'atv':''}}" specvalueid="{{opt['id']}}">{{opt['squareName']}}<em></em></span>
                                                            {{else}}
                                                                <span class="item-con-02-span  {{opt['defaultOption'] == true ? 'atv':'bor-no'}}" specvalueid="{{opt['id']}}">{{opt['squareName']}}<em></em></span>
                                                            {{/if}}
                                                            {{/each}}
                                                            {{if attr['attrSquare']['customMade'] == true }}
                                                            <b class="the_custom_input defInput" style="display: {{canOpen>0?'inline-block':'none'}} " id="span_{{attr['attrSquare']['id']}}_{{part['partId']}}" parentId="{{part['partId']}}" defId="{{attr['attrSquare']['id']}}" attributeValueType="{{attr['attrSquare']['attributeValueType']}}">

                                                                <!--<input type="text" class="zdy" attributeValueType="{{attr['attrSquare']['attributeValueType']}}"><img src="https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop%2Fmall%2Fimage%2Fzy_img_04.png"><input type="text" class="last zdy" attributeValueType="{{attr['attrSquare']['attributeValueType']}}">-->
                                                            </b>
                                                            {{/if}}

                                                        </p>
                                                        {{/if}}
                                                        {{/each}}
                                                    </div>
                                                </li>
                                    </li>
                                </ul>
                        </li>
                        <!--此处是循环部件结束-->
                        {{/each}}
                    </ul>

                </div>

                {{each partAttrOptionList as part }}
                {{if part['partMustChoose'] == false }}
                    <div class="clear_bot"><span class="but_up" id="{{part['partId']}}">可选{{part['partName']}}<em></em></span></div>
                {{/if}}
                {{/each}}

                <div class="product-spec-price-box" style="margin-bottom: 10px">
                    <span class="item-label">运费:</span>
                    <div class="item-content">
                        <span class="spec-attr-text freightPrice">￥<strong>{{basePriceDetail['freightPrice']}} </strong>&nbsp; 预估重量&nbsp; {{weight}}/kg</span>
                    </div>
                </div>

                <div class="product-spec-price-box" style=" display: flex;align-items: center;">
                    <span class="item-label" style="display: block;">款式:</span>
                    <div class="item-content">
                        <em class="input_box" style=" height: auto;">
                            <a href="javascript:void(0);" class="btn-increase">+</a>
                            <input onkeydown="if(event.keyCode==13)return false;" type="text" name="goods[num]" class="action-quantity-input" minbuy="1" value="{{buyCount}}" min="1" max="99999">
                            <a href="javascript:void(0);" class="btn-decrease">-</a>
                        </em>
                    </div>
                </div>

                    <div class="product-spec-price-box">
                        <span class="item-label">总价:</span>
                        <div class="item-content">
                            <span class="spec-attr-text totalPrice"><font>￥<strong>{{basePriceDetail['totalPrice']}}</strong></font>元</span>
                        </div>
                    </div>

            </div>
</script>
        </div>
        <!-------------------图文详情-------------------------------->
        <div class="product_section">
            <div class="product_detail">

                <div class="product-attributes">
                    <span class="atver" name="productDetail">商品详情</span>
                    <span name="afterService">售后服务</span>
                </div>

                <div id="lastDetail"></div>

                <script type="text/html" id="scriptDetail">
                    <div class="detail-content" id="productDetail" style="display: block;">
                        <div class="detail-content-title">商品详情</div>
                        <div class="detail_argument">
                            <!---------详情填充-------->
                            {{if detailInfo.length <1}}
                            <div style="text-align:center;">
                                <img src="https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop/mall/image/pic_pop_04.png">
                            </div>
                            {{else}}
                            {{each detailInfo as detail}}
                            <div style="text-align:center;">
                                <img src="https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/{{detail}}">
                            </div>
                            {{/each}}
                            {{/if}}
                        </div>
                    </div>
                    <div class="detail-content" id="afterService" style="display: none;">
                        <div class="detail-content-title">售后服务</div>
                        <div class="detail_argument">
                            <!---------详情填充-------->
                            <div style="text-align:center;">
                                {{productDesc}}
                            </div>
                        </div>
                    </div>
                </script>

            </div>
        </div>

    </div>

    <!-------------------------------------->
</div>
<script src="http://www.11ziyun.com/js/region.js"></script>
<script src="http://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop/mall/style/library.js"></script>

<!--#} -->

<script>
    loadData();
    function loadData(){
        doAjax("/mall/standradDetails.json","post",{"goodsId":$("input#hiddenGoodsId").val(),"goodsType":$("input#hiddenGoodsType").val()},function (ret) {
            if(ret.code == 1){
                var left = template('left', ret.data);
                var defind = template('defind', ret.data);
                var right = template('right', ret.data);
                var category = template('category', ret.data);
                var lastDetail = template("scriptDetail",ret.data.goodsInfoDetail);
                $("div#defindHtml").html(defind);
                $("span#indexHtml").html(category);
                  $("div#leftHtml").html(left);
                $("div#rightHtml").html(right);
                $(".merchantName").html(ret.data.factoryQuoteInfo.factoryInfoVO.factoryName);
                $(".merchantName").attr('href',"/mall/providerDetail.do?sellerId="+ret.data.sellerDetail.merchantId);
                $(".mobile").html(ret.data.factoryQuoteInfo.factoryInfoVO.contactWay);
                $("#spuName").html(ret.data.spuName);
                $("#brief").html(ret.data.goodsInfoDetail.brief);
                $("#lastDetail").html(lastDetail);
                if(ret.data.canUploadFile == true){
                    $("#canUploadFile").show();
                }else{
                    $("#canUploadFile").hide();
                }
            }else{
                var goods = "<div style=\"height:320px; background:url('https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop/mall/image/pic_pop_04.png') center center no-repeat; text-align:center;  font-size:22px; color:rgb(208,208,208);overflow:hidden;\"><p style=\"margin-top:250px;\">暂无该商品呢,亲 </p></div>";
                $("div.center").html('');
                $("div.center").html(goods);
            }
        });
    }



    //商品 加 购物车 或立即购买
    $(document).on('click','.action-addtocart',function () {
        if(check())return;
        //页面参数效验
        var addCartDto = {};
        $("input[type=hidden].parameter").each(function () {
            var name = $(this).attr('id');
            var value = $(this).val();
            if( name!='spuId'){
                addCartDto[name] = value;
            }else if(name == 'spuId'){
                addCartDto['id'] = value;
            }
        });

        addCartDto['quantity'] = Number($("input.action-quantity-input").val())<=0?1:Number($("input.action-quantity-input").val());//组装数量
        var type = $(this).attr("id");
        if(type=='addcart'){
            addCartDto['operateType'] = 'addcart';
        }else{
            addCartDto['operateType'] = 'buynow';
        }

        //var attrRelateOptList = attributeOptionNames();
        var selfDefineParams = defParam(1);
        var  addCartParam =  addCartAttr();

        addCartDto['quoteAttrOptionMap'] = addCartParam['attributesMap'];
        addCartDto['selfPaperParts'] = addCartParam['selfPaperParts'];
        addCartDto['quoteSelfDefineParamMap'] = selfDefineParams;

        //判断附件input#append
        if( $("input#append").val()){
            var  appendIds =  $("input#append").val().substr(0, $("input#append").val().length-1).split(",");
            addCartDto['appendIds'] = appendIds;
        }

        if(type=='addcart'){//添加购物车
            doAjax("/cart/productAddCart","post",{"addCartDto":JSON.stringify(addCartDto)},function (ret) {
                if(ret.code == 1){
                    $.alert("success","添加购物车成功",1);
                }else{
                    $.alert("error",ret.message,1);
                }
            })
        }else{
        	 if($(this).hasClass('alreadyClicked')){
    			 return;
    		 }
        	$(this).addClass('alreadyClicked');
        	 doAjax("/order/popGoDown/bzRedirectIndex.json","post",{"addCartDto":JSON.stringify(addCartDto)},function (ret) {
             	if(ret.code=="200"){
                    var url="/order/popGoDown/index.do";
                    location.href = url;
                }else{
             	   //返回错误页面
             	   alert(ret.message);
                }
             })
        }
    });

    //组装参数发送ajax请求

    function installParam(obj) {
        if(check())return;
        var goodsParamsVO = {};
        var attrRelateOptList = attributeOptionNames();
        var selfDefineParams = defParam(1);
        var selfPaperSet = [];//自来纸
        $("ul.level1").find("li.product:visible").each(function () {
            if($(this).find("span.the_selfPaper").hasClass("atv")){
                selfPaperSet.push($(this).attr("clsid"));
            }
        });
        $("input[type=hidden].parameter").each(function () {
            var name = $(this).attr('id');
            var value = $(this).val();
            if(name=='spuId'){
                goodsParamsVO['goodsId'] = value;
            }else{
                goodsParamsVO[name] = value;
            }
        });
        goodsParamsVO['quantity'] = Number($("input.action-quantity-input").val())<=0?1:Number($("input.action-quantity-input").val());//组装数量
        goodsParamsVO['areaId'] = $(".input_addr").val();
        goodsParamsVO['partAndAttrRelateOptListMap'] = attrRelateOptList;
        goodsParamsVO['quoteSelfDefineMap'] = selfDefineParams;
        goodsParamsVO['selfPaperSet'] = selfPaperSet;

        var url = "/goods/getSellPrice.json";
        var paramsVO = JSON.stringify(goodsParamsVO);

        doAjax(url,'post',{"goodsParamsVO":paramsVO},function (ret) {
            // var goodsInfo = ret.data;
            //
            // var quoteProcess = "<div>"+ret.data.quoteProcess+"</div>";
            // $.prompt({
            //     style: 'width:900px;left:450px;margin-top:-17%',
            //     title: '算价过程',
            //     con: quoteProcess,
            // });

            if(ret.code==1){
                var right = template('right', ret.data);
                $("div#rightHtml").html(right);
                $("ul.def1").find("li").each(function () {
                    var id = $(this).attr("clsid");
                    $(this).children("ul.def2").find("div.defindDiv").each(function () {
                            var id = $(this).attr('id');
                            var num = id.indexOf("_");
                            var str = id.substr(num,id.length);
                        if($(this).html()!=''){
                            $("#span"+str).html($(this).html());
                            $("#span"+str).siblings(".the_custom").addClass("atv");
                        }
                        if($(this).attr('custom') == 'show'){
                            $("#son"+str).css("display",'inline-block');
                        }

                    });
                    $(this).children("ul.def2").find("div.paperDiv").each(function () {
                        if($(this).attr("selfId") == 1){
                            var id = $(this).attr('id');
                            var num = id.indexOf("_");
                            var str = id.substr(num,id.length);
                            $("#self"+str).addClass("atv");
                        }
                    });
                    if($(this).attr("gongyi") == "true"){
                        $("p[gongyiid="+$(this).attr("clsid")+"]").find("em.tianjia").addClass("atv");
                        $("li[gongyiid="+$(this).attr("clsid")+"]").show();
                    }

                    if($(this).attr("status") == 'show'){
                        $("ul.level1").find("ul.product-buy-ul[noneid="+id+"]").css("display","block");
                    }else{
                        $("ul.level1").find("ul.product-buy-ul[noneid="+id+"]").css("display","none");
                    }
                });

            }else{
                loadData();
                $.alert("error",ret.message,1);

            }
        });
    }


    //加入购物车参数组装

    function addCartAttr(){
        var addCartParam = {};
        // 1)组织 attributesMap ： 找到每个最外层后
        var attributesMap = {};
        var cur = null;	//当前产品
        var  selfPaperParts = [];
        //循环当前部件的ul
        $("ul.level1").children("li:visible").find("ul.level2:visible").each(function () {
            cur = $(this).attr('noneid');
            attributesMap[cur] = {};
            if($(this).find("span.selfPaper").hasClass("atv")){
                selfPaperParts.push(cur);
            }
            $(this).find(".item-con-01[optionid]").each(function () {

                var type = $(this).attr("attributevaluetype");
                var v = "";
                if($(this).find("select").length==1){
                    v = $(this).find("select option:selected").val();
                }else if($(this).find("select").length==2){
                    v = $(this).find("select").eq(1).val();
                }else{
                    v = $(this).find("span.atv").attr("specvalueid");
                }
                attributesMap[cur][type] = v==''?'0':v;
            });
//工艺参数
            $(this).find(".item-con-02[optionid]").each(function () {
                if($(this).find("span.item-con-02-span:visible").hasClass("atv")){
                    var type = $(this).attr("attributevaluetype");
                    var v = $(this).find("span.atv").attr("specvalueid");
                    attributesMap[cur][type] = v==''?'0':v;
                }
            });
        });
        addCartParam['attributesMap'] = attributesMap;
        addCartParam['selfPaperParts'] = selfPaperParts;
        return addCartParam;
    }



    //显示可选部件
    $(document).on('click',".but_up",function(){
        var id = $(this).attr("id");

       if($("ul.def1").find("li[clsid="+id+"]").attr("status") == 'hide'){
           $("ul.def1").find("li[clsid="+id+"]").attr("status","show");
           $("ul.level1").find("ul.product-buy-ul[noneid="+id+"]").css("display","block");

       }else{
           $("ul.def1").find("li[clsid="+id+"]").attr("status","hide");
           $("ul.level1").find("ul.product-buy-ul[noneid="+id+"]").css("display","none");

       }
        installParam();

    });

    //变化传参
    function attributeOptionNames(){
        var partAndAttrRelateOptListMap = {};
        $("ul.level1").children("li.product").find("ul:visible").each(function () {
            $(this).parent("li.product").each(function () {
                var attributeOptionNames = [];
                $(this).find("p.item-con-01").each(function () {
                    var obj = $(this);
                    var attrOpt = {};
                    var squre = {};
                    squre['id'] = obj.attr('optionid');
                    squre['attributeType'] = obj.attr('attributetype');
                    squre['attributeKey'] = obj.attr('attributekey');
                    squre['influenceCraftPriceType'] = obj.attr('influencecraftpricetype');
                    squre['joinBuildSku'] = obj.attr('joinbuildsku');
                    squre['attributeValueType'] = obj.attr('attributevaluetype');
                    attrOpt['squareVO'] = squre;
                    if(obj.find("select").length==1){
                        //说明有下拉框
                        attrOpt['optionId'] = $(this).find("select option:selected").val();
                        attributeOptionNames.push(attrOpt);
                    }else if(obj.find("select").length==2){
                        //说明是材料
                        attrOpt['optionId'] = $(this).find("select.optionKey option:selected").val();
                        attributeOptionNames.push(attrOpt);
                    }else{
                        //说明是展开 需要平铺
                        obj.find("span.item-con-01-span").each(function () {
                            if($(this).hasClass("atv")){
                                attrOpt['optionId'] = $(this).attr('specvalueid');
                                attributeOptionNames.push(attrOpt);
                            }
                        });
                    }
                });
                //组装后道工艺的参数
                $(this).find("p.item-con-02:visible").each(function () {
                    var obj = $(this);
                    obj.find("span.item-con-02-span").each(function () {
                        if($(this).hasClass("atv")){
                            var attrOpt = {};
                            var squre = {};
                            squre['id'] = obj.attr('optionid');
                            squre['attributeType'] = obj.attr('attributetype');
                            squre['attributeKey'] = obj.attr('attributekey');
                            squre['influenceCraftPriceType'] = obj.attr('influencecraftpricetype');
                            squre['joinBuildSku'] = obj.attr('joinbuildsku');
                            squre['attributeValueType'] = obj.attr('attributevaluetype');
                            attrOpt['squareVO'] = squre;
                            attrOpt['optionId'] = $(this).attr('specvalueid');
                            attributeOptionNames.push(attrOpt);
                        }
                    });
                });
            var partId = $(this).attr("clsid");
            partAndAttrRelateOptListMap[partId] = attributeOptionNames;
            })

        });
        return partAndAttrRelateOptListMap;
    }

    //组装自定义的参数
    function defParam(num){
        var selfDefineParams = {};

        $("ul.level1").children("li.product").find("ul:visible").each(function () {
            $(this).parent("li.product").each(function () {
                var map = {};
                $(this).find(".defInput:visible").each(function () {
                    var obj = $(this);
                    if(obj.find("input").length>=1){
                        var str = "";
                        obj.find("input").each(function () {
                            str+=$(this).val()+",";
                        });
                        str = str.substr(0,str.length-1).split(",");
                        var key = "";
                        if(num == 1){
                            key = obj.attr("attributeValueType");
                        }else{
                            key = obj.attr("defId");
                        }
                        map[key]=str;
                    }
                });
                var partId = $(this).attr("clsid");
                selfDefineParams[partId] = map;
            })
        })
        // $("ul.level1").find("li.product:visible").each(function () {
        //     var map = {};
        //     $(this).find(".defInput:visible").each(function () {
        //         var obj = $(this);
        //         if(obj.find("input").length>=1){
        //             var str = "";
        //             obj.find("input").each(function () {
        //                 str+=$(this).val()+",";
        //             });
        //             str = str.substr(0,str.length-1).split(",");
        //             var key = "";
        //             if(num == 1){
        //                 key = obj.attr("attributeValueType");
        //             }else{
        //                 key = obj.attr("defId");
        //             }
        //             map[key]=str;
        //         }
        //     });
        //       var partId = $(this).attr("clsid");
        //     selfDefineParams[partId] = map;
        // });
        return selfDefineParams;
    }


    //输入框 绑定未来事件
    $(document).on("change","p input.zdy",function () {

        var id = $(this).parent().attr('defId');
        var parentId = $(this).parent().attr('parentId');

        //判断输入是否符合
        var v1 = $(this).val();
        if( isNaN(v1) || parseFloat(v1)<=0 || -1 !== v1.indexOf('-') ){
            $.alert("error","数据填写不合法",0);
            $(this).val('');
            return;
        }

        var max = $(this).attr('max');
        var min = $(this).attr('min');
        if(max=='' || min==''){
            $.alert("error","自定义长度配置错误",0);
            return;
        }
        if( parseFloat(min) > parseFloat(v1) || parseFloat(max) < parseFloat(v1) ){
            $.alert("error","数据填超出合法范围",0);
            $(this).val('');
            return;
        }

        //【P数】 骑马钉、锁线胶装必须是4的倍数
        var divNum = $(this).attr('attributeValueType');
        var  qmd = "";
        if($("select[attributevaluetype=zhuangding_fangshi]").length>0){
            qmd = $("select[typevalue=zhuangding_fangshi] option:selected").text();
        }else{
            qmd = $("p[attributevaluetype=zhuangding_fangshi]").find("span.atv").text();
        }
        if( Boolean(divNum) && divNum === "p_value" ){
            if(qmd === "骑马钉" || qmd === "锁线胶装"){
                if( v1 % 4 !== 0 ){
                    $.alert("error","当【装订方式】选择 [骑马钉] 或者 [锁线胶装] 的时候，【P数】自定义值必须是 4 的倍数！'",0);
                    $(this).val('');
                    return;
                }
            }
        }

        $(this).attr('value',v1);
        if($(this).val()){   //如果自己变化的有值
            if($(this).siblings("input").length){
                var inputNum = 0;
                $(this).siblings("input").each(function () {
                    if($(this).val()){
                        inputNum++;
                    }
                });
                if(inputNum == $(this).siblings("input").length){
                    $("ul.def2").find("#div_"+id+"_"+parentId+"").html($(this).parent().html());
                    installParam();
                }
            }else{
                $("ul.def2").find("#div_"+id+"_"+parentId+"").html($(this).parent().html());
                installParam();
            }
        }

    });

    //点击材料改变显示的克重

    $(document).on("change","select.materialKey",function () {
        var val = $(this).val();
        $(this).parent().next("span").find("select option").each(function () {
            $(this).removeAttr('selected');
            if($(this).attr("optionKey") == val){
                $(this).css("display","block");
            }else{
                $(this).css("display","none");
            }
        });

        $(this).parent().next("span").find("select option[optionKey="+val+"]").eq(0).attr('selected','selected');
        $(this).parent().next("span").find("select").val($(this).parent().next("span").find("select option[optionKey="+val+"]").eq(0).val());
        //【重要】要触发change事件，执行排他规则
        installParam();

    })


    $(document).on("change","select",function () {
        installParam();
    });


    //正常参数d单选 排除下拉框
    $(document).on('click',".item-con-01 .item-con-01-span",function(){
        var id = $(this).attr("defId");
        var parentId = $(this).attr("parentId");

        var attrcandef = $(this).parents("p[attributevaluetype]").next("p.defindArea").attr('attrcandef');
        if(attrcandef == 1 && $(this).attr("definitionlength") && $(this).attr("definitionlength").length>2){
            var attributeValueType = $(this).parents("p[attributevaluetype]").attr('attributevaluetype');

            var definitionlength = $(this).attr("definitionlength");
            var str = definitionlength.replace(/\[/g,""); str = str.replace(/\]/g,""); var array = str.split(","); var size = array.length/2 >=1 ? 2:1;
            array = chunk(array,size);//组装成需要的数组

            //动态拼接html
            var maxmin = array.shift();//删除最前的一个元素，并返回
            var html = "";
            if(array.length==0){
                html += "<input type='text' class='the_custom_ipt last zdy' placeholder="+maxmin[0]+"~"+maxmin[1]+"  max="+maxmin[1]+" min="+maxmin[0]+" attributeValueType="+attributeValueType+">";
            }else{
                html += "<input type='text' class='the_custom_ipt zdy' placeholder="+maxmin[0]+"~"+maxmin[1]+"  max="+maxmin[1]+" min="+maxmin[0]+" attributeValueType="+attributeValueType+">";
            }
            if(array.length > 0){
                for(var i=0;i<array.length;i++){
                    html+="<img src='https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop%2Fmall%2Fimage%2Fzy_img_04.png'> ";
                    if(i == array.length-1){
                        html+="<input type='text' class='the_custom_ipt last zdy' placeholder="+array[i][0]+"~"+array[i][1]+"  max="+array[i][1]+" min="+array[i][0]+" attributeValueType="+attributeValueType+">";
                    }else{
                        html+="<input type='text' class='the_custom_ipt zdy ' placeholder="+array[i][0]+"~"+array[i][1]+"  max="+array[i][1]+" min="+array[i][0]+" attributeValueType="+attributeValueType+">";
                    }
                }
            }
            $(this).parents("p[attributevaluetype]").next("p.defindArea").find("span.the_custom").addClass("atv").show();
            $("ul.def2").find("#div_"+id+"_"+parentId+"").attr('custom','show');
            //编辑不可点击 必选
            $(this).parents("p[attributevaluetype]").next("p.defindArea").find("span.defInput").show();
            $(this).parents("p[attributevaluetype]").next("p.defindArea").find("span.defInput").html(html);
            $(this).addClass('atv').siblings().removeClass('atv');
            return;
        }else if(attrcandef == 1){
            $(this).parents("p[attributevaluetype]").next("p.defindArea").find("span.the_custom").hide();
            $(this).parents("p[attributevaluetype]").next("p.defindArea").find("span.defInput").hide();
            $(this).parents("p[attributevaluetype]").next("p.defindArea").find("span.defInput").html('');
            $(this).addClass('atv').siblings().removeClass('atv');
            $("ul.def2").find("#div_"+id+"_"+parentId+"").html('');
            $("ul.def2").find("#div_"+id+"_"+parentId+"").attr('custom','hide');
            installParam($(this));
            return;
        }

        if($(this).find("select").length>=1)
        {
            return;
        }

        if($(this).hasClass("mutual")){
            return;
        }
        if(!$(this).hasClass('atv'))
        {
            $(this).addClass('atv').siblings().removeClass('atv')
            installParam($(this));
        }
        // else{
        //     $(this).removeClass('atv')
        // }
    })


    //点击显示工艺
    $(document).on('click',".item-con-02 .atv_show",function(){
        var defLength = $(this).attr("customLimitValue");
        var id = $(this).attr("defId");
        var parentId = $(this).attr("parentId");
        var attributeValueType = $(this).attr("attributevaluetype");

        if(!$(this).hasClass("atv"))
        {
            $(this).addClass('atv');
            if(defLength){
                var str = defLength.replace(/\[/g,""); str = str.replace(/\]/g,""); var array = str.split(","); var size = array.length/2 >=1 ? 2:1;
                array = chunk(array,size);//组装成需要的数组

                //动态拼接html
                var maxmin = array.shift();//删除最前的一个元素，并返回
                var html = "";
                if(array.length==0){
                    html += "<input type='text' class='the_custom_ipt last zdy' placeholder="+maxmin[0]+"~"+maxmin[1]+"  max="+maxmin[1]+" min="+maxmin[0]+" attributeValueType="+attributeValueType+">";
                }else{
                    html += "<input type='text'  class='the_custom_ipt zdy' placeholder="+maxmin[0]+"~"+maxmin[1]+"  max="+maxmin[1]+" min="+maxmin[0]+" attributeValueType="+attributeValueType+">";
                }
                if(array.length > 0){
                    for(var i=0;i<array.length;i++){
                        html+="<img src='https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop%2Fmall%2Fimage%2Fzy_img_04.png'> ";
                        if(i == array.length-1){
                            html+="<input type='text' class='the_custom_ipt last zdy' placeholder="+array[i][0]+"~"+array[i][1]+"  max="+array[i][1]+" min="+array[i][0]+" attributeValueType="+attributeValueType+">";
                        }else{
                            html+="<input type='text' class='the_custom_ipt zdy ' placeholder="+array[i][0]+"~"+array[i][1]+"  max="+array[i][1]+" min="+array[i][0]+" attributeValueType="+attributeValueType+">";
                        }
                    }
                }
                $("#span_"+id+"_"+parentId).html(html);
            }
            $(this).next("span").addClass("atv").siblings(".the_custom_input").css("display","inline-block");

            if($(this).next("span").siblings(".the_custom_input").length==0){
                installParam();
            }
            $(this).parents("p").find(".item-con-02-span").removeClass('bor-no')

        }
        else{

            $(this).removeClass('atv');
            $(this).parents("p").find(".item-con-02-span").addClass('bor-no').removeClass("atv")
            $(this).parents("p").find(".the_custom_input").css("display","none");
            installParam();

        }

    });

    //工艺参数d单选
    $(document).on('click',".item-con-02 .item-con-02-span",function(){
        if(!$(this).hasClass('bor-no'))
        {
            if(!$(this).hasClass('atv'))
            {
                $(this).addClass('atv').siblings('span').removeClass('atv');
                $(this).siblings(".the_custom_input").css("display","inline-block");
                installParam();
            }else{
                //  $(this).removeClass('atv')
                //$(this).siblings(".the_custom_input").css("display","none");
            }
        }
    });

    //添加工艺显示
    $(document).on('click',".tianjia",function(){
        var gongyiId = $(this).parent("p").attr("gongyiid");
        if(!$(this).hasClass("atv")){
            $(this).addClass('atv');
            $(this).parents("ul[noneid]").find(".gongyi").css("display","block")

            //记录此勾选
            $("div#defindHtml").find("li[clsid="+gongyiId+"]").attr("gongyi",true);
        }
        else{
            $(this).removeClass('atv');
            $(this).parents("ul[noneid]").find(".gongyi").css("display","none");
            $("div#defindHtml").find("li[clsid="+gongyiId+"]").removeAttr("gongyi");
            //判断是否有勾选
            if($(this).parents("ul[noneid]").find(".gongyi").find("span.item-con-02-span.atv").length>0){
            installParam();
            }
        }
    })


    //勾选框点击 判断是否是自来纸还是自定义
    $(document).on('click',".the_custom",function(){
        if($(this).hasClass("noClick")){
            return false;
        }
        if($(this).hasClass("the_selfPaper")){
            var id = $(this).attr("id");
            id = id.substr( id.indexOf("_"),id.length);
            if(!$(this).hasClass("atv")){
                $(this).addClass('atv');
                $("ul.def2").find("#div"+id).attr("selfId",1);
                installParam();
                return
            }else{
                $(this).removeClass('atv');
                $("ul.def2").find("#div"+id).attr('selfId',0);
                installParam();
                return
            }
        }
        //得到自定义的长度
        var defLength = $(this).attr("val");
        var id = $(this).attr("defId");
        var parentId = $(this).attr("parentId");
        var attributeValueType = $(this).attr("attributevaluetype");

        if(!$(this).hasClass("atv")){
            if(defLength){
                var str = defLength.replace(/\[/g,""); str = str.replace(/\]/g,""); var array = str.split(","); var size = array.length/2 >=1 ? 2 : 1;
                array = chunk(array,size);//组装成需要的数组
                //动态拼接html
                var maxmin = array.shift();//删除最前的一个元素，并返回
                var html = "";
                if(array.length==0){
                    html += "<input type='text' class='the_custom_ipt last zdy' placeholder="+maxmin[0]+"~"+maxmin[1]+"  max="+maxmin[1]+" min="+maxmin[0]+" attributeValueType="+attributeValueType+">";
                }else{
                    html += "<input type='text'  class='the_custom_ipt zdy' placeholder="+maxmin[0]+"~"+maxmin[1]+"  max="+maxmin[1]+" min="+maxmin[0]+" attributeValueType="+attributeValueType+">";
                }
                if(array.length > 0){
                    for(var i=0;i<array.length;i++){
                        html+="<img src='https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/pop%2Fmall%2Fimage%2Fzy_img_04.png'> ";
                        if(i == array.length-1){
                        html+="<input type='text' class='the_custom_ipt last zdy' placeholder="+array[i][0]+"~"+array[i][1]+"  max="+array[i][1]+" min="+array[i][0]+" attributeValueType="+attributeValueType+">";
                        }else{
                        html+="<input type='text' class='the_custom_ipt zdy ' placeholder="+array[i][0]+"~"+array[i][1]+"  max="+array[i][1]+" min="+array[i][0]+" attributeValueType="+attributeValueType+">";
                        }
                    }
                }
                $("#span_"+id+"_"+parentId).html(html);
            }
            $(this).addClass('atv');
            $(this).parent("p.item-con").prev("p.item-con-01").find(".ziding_dow").attr("disabled","disabled");

        }
        else{

            //不可选
            $(this).removeClass('atv');
            $("#span_"+id+"_"+parentId).html('');
            $("#div_"+id+"_"+parentId).html('');
            $(this).parent("p.item-con").prev("p.item-con-01").find(".ziding_dow").removeAttr("disabled");
            installParam();
        }
    })


    $(function(){
        //相册
        $.zy_scroll('.thumbnail-list','.flip_prev','.flip_next','.thumbnail-list',4,false);
        $(document).on('click',".thumbnail-list ul li",function () {
            $(this).addClass('atver').siblings().removeClass('atver');
            $('.product-album-preview').find("img").attr("src",$(this).find("img").attr("src")).css("opacity",0).stop().animate({opacity:1});
        });

        //收藏
        $(document).on('click','.addfav',function(){
            var redirect_url = 'http://www.11ziyun.com/login';
            if(redirect_url=='1'){
                if($('.addfav i').attr("value")=='1'){
//                $.alert('error', '商品已收藏',1);return;
                    var goodsId = $('.goodsID').val();
                    $(this).find('i').removeClass('atver');
                    doAjax('http://www.11ziyun.com/member/del-collect-goods','post',{'goodsId':goodsId},function(data){
                        if(data['result']=='1'){
                            $('.addfav i').attr('value',0)
                            $.alert('success', '取消成功');return;
                        }else{
                            $.alert('error', '取消失败');return;
                        }
                    })
                }else{
                    var info = {};
                    info['goodsIds'] = $('.goodsID').val();
                    $(this).find('i').addClass('atver')
                    doAjax('http://www.11ziyun.com/member/do-collect-goods','post',info,function(data){
                        if(data['result']=='1'){
                            $('.addfav i').attr('value',1)
                            $.alert('success', '收藏成功');return;
                        }else{
                            $.alert('error', '收藏失败');return;
                        }
                    })
                }
            }
            else{
                window.location.href=redirect_url;return;
            }
        })



        //减少数量
        $(document).on('click','.btn-decrease',function(){
            var pic_buy='';
            var input_obj = $(".action-quantity-input");
            var cur_val = Number(input_obj.val());
            if(cur_val  <=1 )return;
            CountAnim(this,cur_val+'',(cur_val-1)+'',-40);
            input_obj.val(Number(cur_val-1));
            if($('.product-big-title span.atver').attr('unit')=='ream')
            {
                pic_buy=Number($('.lPrice').val());
            }
            else if($('.product-big-title span.atver').attr('unit')=='ton')
            {
                pic_buy=Number($('.dPrice').val())
            }
            else if($('.spec-price-box-design.atver').attr('design_cost'))
            {
                pic_buy=Number($('.spec-price-box-design.atver').attr('design_cost'))
                $('.design_cost').text(pic_buy*input_obj.val())
                var urgent = $('.urgent_box .atver').attr('urgent');
                $('.select-design_urgent').text(urgent*input_obj.val());
            }
            else
            {
                pic_buy=Number($('input.price').val())
            }
            if($('.urgent_button').hasClass('atver'))
            {
                $('.urgent').text(input_obj.val()*Number($('.urgent_button').attr('urgent')))

            }

            num_data(pic_buy,input_obj.val())
//            if($('.addcartBuyType').val()=='design_service'){
//                $(".total_num").text(Number($(".select-design_cost").text())+Number($(".select-design_urgent").text()))
//            }else{
//                $(".total_num").text(Number($(".design_cost").text())+Number($(".urgent").text()))
//            }
        });

        //增加数量
        $(document).on('click','.btn-increase',function(){
            var input_obj = $(".action-quantity-input");
            var cur_val = Number(input_obj.val());
            var store = $('.store').val();
            var nostoreSell = $('.nostoreSell').val();
            if(cur_val  >=99999 )return;
//            if(!nostoreSell)
//            {
//                if(input_obj.val()>=store)
//                {
//                    $.alert('error', '库存不足');return;
//                }
//            }
            CountAnim(this,cur_val+'',(cur_val+1)+'',-40);
            input_obj.val(Number(cur_val+1));
            var pic_buy='';
            if($('.product-big-title span.atver').attr('unit')=='ream')
            {
                pic_buy=Number($('.lPrice').val())
            }
            else if($('.product-big-title span.atver').attr('unit')=='ton')
            {
                pic_buy=Number($('.dPrice').val())
            }
            else if($('.spec-price-box-design.atver').attr('design_cost'))
            {
                pic_buy=Number($('.spec-price-box-design.atver').attr('design_cost'))
                $('.design_cost').text(pic_buy*input_obj.val())
                var urgent = $('.urgent_box .atver').attr('urgent');
                $('.select-design_urgent').text(urgent*input_obj.val());
            }
            else
            {
                pic_buy=Number($('input.price').val())
            }
            if($('.urgent_button').hasClass('atver'))
            {
                $('.urgent').text(input_obj.val()*Number($('.urgent_button').attr('urgent')))
            }

            num_data(pic_buy,input_obj.val());
//            if($('.addcartBuyType').val()=='design_service'){
//                $(".total_num").text(Number($(".select-design_cost").text())+Number($(".select-design_urgent").text()))
//            }else{
//                $(".total_num").text(Number($(".design_cost").text())+Number($(".urgent").text()))
//            }
        });

        $(document).on('change','.action-quantity-input',function(){
            var pic_buy='';
            var num = $(this).val();
            if(isNaN(num)){
                $(this).val(1);return;
            }
            if($('.product-big-title span.atver').attr('unit')=='ream')
            {
                pic_buy=Number($('.lPrice').val());
                num = Number(num).toFixed(3);
            }
            else if($('.product-big-title span.atver').attr('unit')=='ton')
            {
                pic_buy=Number($('.dPrice').val());
                num = Number(num).toFixed(6);
            }
            else if($('.spec-price-box-design.atver').attr('design_cost'))
            {
                var urgent = $('.urgent_box .atver').attr('urgent');
                pic_buy=Number($('.spec-price-box-design.atver').attr('design_cost'))
                $('.design_cost').text(pic_buy*$(this).val());
                $('.select-design_urgent').text(urgent*$(this).val());
                num = Number(num).toFixed(0);
            }
            else
            {
//                var store = $('.store').val();
//                var nostoreSell = $('.nostoreSell').val();
//                if(!nostoreSell)
//                {
//                    if(num>=store)
//                    {
//                        $.alert('error', '库存不足');
//                        num = store;
//                        $(this).val(store);
//                    }
//                }
                pic_buy=Number($('input.price').val());
                num = Number(num).toFixed(0);
            }
            if($('.urgent_button').hasClass('atver'))
            {
                $('.urgent').text($(this).val()*Number($('.urgent_button').attr('urgent')))
            }
//            if($('.addcartBuyType').val()=='design_service'){
//                $(".total_num").text(Number($(".select-design_cost").text())+Number($(".select-design_urgent").text()))
//            }else{
//                $(".total_num").text(Number($(".design_cost").text())+Number($(".urgent").text()))
//            }
            num_data(pic_buy,num)
        })
        //数量加减计算
        function num_data(pic,num,dis)
        {
            var info = {};
            if(num>=99999){
                num = 99999;
            }

            installParam();//组装参数

        }

        var CountAnim=function(obj,j,l,num){
            var txtCount = $('.action-quantity-input');
            var p=$(obj).parents('.input_box');
            var k='';
            var j=j.split('');
            txtCount.css('color','#fff');
            for (var s = 0; s < j.length; s++)
            {
                k += '<i style="position:relative;">' + j[s] + "</i>";
            }
            p.prepend('<i class="upspan" >' + k + "</i>");

            var m='';
            var l=l.split('');
            for (var n = 0; n <l.length; n++)
            {
                m += '<i style="position:relative;">' + l[n] + '</i>';

            }
            p.append('<i class="downspan" style="top:'+(-num)+'px;">' + m + "</i>");
            var d = $(".downspan i:last");
            var u= $(".upspan i:last");

            u.animate({top: num}, "10");
            d.animate({top: num}, "10",function(){
                $('.downspan,.upspan').remove();
                txtCount.css('color','#333');
            });
        }
    });

    //地址
    $(".address_text").hover(function(){
        $(".address_select").show();
        if($(".address_tab span").index('.atver')!=-1)
        {
            $(".address_con").eq(0).show();
        }


    },function(){

        $(".address_select").hide();
        $(".address_con").hide().eq(1).show();
        $(".address_tab i").eq(2).text('请选择').hide();
        $(".address_tab span").removeClass('atver').eq(1).addClass('atver');
    })
    $(".address_tab span").each(function(i, o) {
        $(o).click(function(){
            $(o).addClass('atver').siblings().removeClass('atver');
            $(".address_con").hide().eq(i).show();
        })
    });
    $.select_add('address_op',region_Data,1323);//默认湖北武汉江汉区
    $(".address_con").each(function(i, o) {
        $(o).html($(".address_op").eq(i).html());
        $(o).find("option").each(function(index, element) {
            $(element).wrapAll(document.createElement("span"));
        });
        $(o).on('click','option',function(){
            $(".address_op").eq(i).val($(this).attr('value'))
            $(".address_tab span").eq(i).find('i').text($(this).text());
            var id=$(this).attr('value')
            add_div(region_Data,id,i);
        })
    });

    function add_div(jsonData,id,index)
    {
        getJsonLength=function(jsonData)
        {
            var jsonLength = 1;
            for(var item in jsonData){
                jsonLength++;
            }
            return jsonLength;

        };

        var len=getJsonLength(region_Data);

        if(index==0)
        {
            $(".address_con").eq(1).html('');
            $(".address_con").eq(2).html('');
            $(".address_tab i").eq(1).text('请选择');
            $(".address_tab i").eq(2).text('请选择').hide();
            //for(var i=1;i<len;i++)
            for ( i in jsonData)
            {
                if(jsonData[i]!=undefined && jsonData[i]['p_region_id']==id)
                {
                    $(".address_con").eq(1).append("<option value="+jsonData[i]["region_id"]+">"+jsonData[i]["local_name"]+"</option>");

                }
            }
            $(".address_con").eq(1).find("option").each(function(index, element) {
                $(element).wrapAll(document.createElement("span"));
            });
            $(".address_tab span").removeClass("atver").eq(1).addClass("atver");
            $(".address_con").hide().eq(1).show();

        }
        if(index==1)
        {
            $(".address_con").eq(2).html('');
            $(".address_tab i").eq(2).text('请选择').show();
            //for(var i=1;i<len;i++)
            for ( i in jsonData)
            {
                if(jsonData[i]!=undefined && jsonData[i]['p_region_id']==id)
                {
                    $(".address_con").eq(2).append("<option value="+jsonData[i]["region_id"]+">"+jsonData[i]["local_name"]+"</option>")

                }
            }
            $(".address_con").eq(2).find("option").each(function(index, element) {
                $(element).wrapAll(document.createElement("span"));
            });
            if($(".address_con").eq(2).text()=='')
            {
                $(".address_tab span").eq(2).hide().html('<i></i>');
                $(".address_text a").text($(".address_tab").text());
                $(".address_select").hide();
                $(".input_addr").val(id);

                installParam();

            }
            else
            {
                $(".address_tab span").eq(2).show().html('<i>请选择</i>');

            }
            $(".address_tab span").removeClass("atver").eq(2).addClass("atver");
            $(".address_con").hide().eq(2).show();
        }
        if(index==2)
        {
            $(".address_text a").text($(".address_tab").text());
            $(".address_select").hide();
            $(".input_addr").val(id);

            installParam();
        }
    }

    //切割数组，分组
    function chunk(arr,size){
        var arr1 = [];
        if(size>1){
            for(var i=0;i<arr.length;i=i+size){
                var arr2 =arr;
                arr1.push(arr2.slice(i,i+size));
            }
            return arr1;
        }else{
            arr1.push(arr.slice(0,2));
            return arr1;
        }
    }

</script>
<script>
    //商品上传附件
    var fileIdList="";
    var i = 0;
    $.files_up_oss({
        id:['uploadFile'],//按钮id
        url: "/oss/getSignatureNew",
        dir: "order/orderImage/",
        file_type: "jpg,png,gif,psd,ai,cdr,eps,ppt,word,excel,pdf,tiff,rar,zip,7z,gif",
        size: "100mb",//mb
        view_url: "https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/"
    },function(index_number,json){
        if (json.Status == 'OK') {
            i++;
            $("#fileNum").val(json.total);
            var requestData={
                url:json.filename,
                name:json.filename,
                size:json.size,
                type:json.mimeType,
                uniqueId:(new Date()).valueOf()
            }

            doAjax("/user/userAccessory/addAccessory.json", 'post', {'requestData':JSON.stringify(requestData)}, function(ret){
                var fileId=ret.data.resultDtos[0].id;
                $("input#append").val( $("input#append").val()+fileId+",");
                var html = "<em class='fileEm'>\n" +
                    " <a href=\"javascript:\" style=\"text-decoration:none;color: #6647b2;display: inline-block;width: 100px;height:34px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;vertical-align: top;\">"+json.filename+"</a>\n" +
                    "  <i class=\"del\" style=\"margin-top: 5px;;display: inline-block;width: 15px;height: 15px;cursor: pointer; margin-left: 15px; color: #f16c6c; line-height: 15px;text-align: center;\" aid="+fileId+">X</i>\n" +
                    " </em>"
                $(".picture").append(html);
            });
        }
        if(json.total>1){
            $("span.moreFile").show();
        }
    });


    //删除附件
    $(document).on('click',"i.del",function () {
        var aid = $(this).attr('aid');
        $(this).parent().remove();
        if($("em.fileEm").length<2){
            $("span.moreFile").hide();
        }
        var appendArr =  $("input#append").val().substr(0, $("input#append").val().length-1).split(",");
        appendArr.splice($.inArray(aid,appendArr),1);//剔除当前元素
        if(appendArr.length == 0){
        $("input#append").val('');
        }else{
        $("input#append").val(appendArr.toString()+",");
        }
    });

    var flag = true;
    $(document).on("click","span.moreFile",function () {
        if(flag){
            flag = false;
            $("span.picture").css("height","auto");
        }else{
            flag = true;
            $("span.picture").css("height","30px");
        }
    });

    function check() {
        var count = 0;
        //页面参数效验
        $('input.zdy:visible').each(function(){
            if( $(this).val() == '' ){
                $.alert("error","自定义数据请填写完整!",0.5);
                count++ ;
                return false;
            }
        });
        return count;
    }
    $(document).on("click","div.product-attributes>span",function () {
        $(this).addClass("atver").siblings().removeClass("atver");
        $("#"+$(this).attr("name")).show().siblings("div").hide();
    })

</script>
